-
Notifications
You must be signed in to change notification settings - Fork 0
Role and Permission provisioning for user #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
40627a0
to
68b456a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments about sql injection concerns, but lgtm
return nil, nil, fmt.Errorf("unexpected database id: %s", splitId[1]) | ||
} | ||
|
||
permission := splitId[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe we want a helper function for extracting parts of an id
} | ||
|
||
dbName := splitId[1] | ||
roleId := splitId[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe helper function?
return fmt.Errorf("invalid characters in dbName or user") | ||
} | ||
|
||
command := fmt.Sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this sprintf safe? should we escape? from the perspective of just this function, with encapsulation in mind where do not assume we know who called this function and with what arguments, we're concatenating unknown unescaped strings into a query against someone's prod database and we don't have any idea of what these strings are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQL Server’s limitation, no driver alows us to bind table names, permissions or db.
Like normal command SELECT * FROM user WHERE Id = @p1
we can't use this for grant
Ex: "GRANT @p1 ON DATABASE::[@p2] TO [@p3];"
return fmt.Errorf("invalid characters in dbName or user") | ||
} | ||
|
||
command := fmt.Sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: sprintf
l := ctxzap.Extract(ctx) | ||
l.Debug("getting database role", zap.String("id", id), zap.String("dbName", dbName)) | ||
|
||
if strings.ContainsAny(dbName, "[]\"';") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this enough escaping?
Increase bato-sdl
Add database user provisioning
Provisioning for role and permission
if the user does not exist in the database, create with the current server principal